// $Id: loggerdownloadspeed.h 54 2004-10-11 15:31:22Z jonas $
#ifndef LOGGERDOWNLOADSPEED_H
#define LOGGERDOWNLOADSPEED_H

#include "loggercount.h"
#include "node.h"
#include "transfer.h"
#include <map>
#include <vector>

/**
 * This logger logs the acctual transfer speeds for files a node itself
 * requested. The routing transfers carried out by neighboring nodes does not
 * have any effect.
 */
class LoggerDownloadSpeed : public LoggerCount {
public:
	LoggerDownloadSpeed();
	~LoggerDownloadSpeed();

	void eos_simulate_start(void *);
	void eos_simulate_stop(void *);
	void node_transfer(void *, void *, unsigned char);
	void clock_tick(unsigned int);

private:
	class TransferHelper {
	public:
		TransferHelper();
		TransferHelper(Node *, Transfer *);

		Node *m_node;
		Transfer *m_transfer;
		unsigned int m_timeStart;
	};
	std::map<unsigned int, TransferHelper> m_transfers;

	class NodeSpeedHelper {
	public:
		NodeSpeedHelper(Node *);

		void addSample(int);
		Node *m_node;
		int m_transferSpeed;
		int m_sampleCount;
	};
	//std::map<Node *, NodeSpeedHelper *> m_nodeSpeeds;
	std::vector<std::map<Node *, NodeSpeedHelper *> *> m_nodePartitionSpeeds;

	void storeTransfer(Transfer *);

	Eos *m_eos;
	std::fstream m_fout;
	Transfer *m_lastTransfer;
};

#endif
